package com.aloda.orangebank.controller;

import com.aloda.orangebank.pojo.Result;
import com.aloda.orangebank.utils.AliOSSUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@Slf4j
@RestController
public class UploadController {

    @Autowired
    private AliOSSUtils aliOSSUtils;

    @PostMapping("/upload")
    public Result upload(MultipartFile file)throws IOException {
        String url= aliOSSUtils.upload(file);
//        String url= "https://web-tlias-aloda.oss-cn-beijing.aliyuncs.com/8327e40f-71c4-4e07-8342-11009ee798ca.jpg";
        log.info("图片上传{}",url);
        return Result.success(url);
    }
}
